#include <cstdio>
#include <list>

using namespace std; 

int main()
{
	list<int> a; 
	list<int>::iterator it; 
	int i, n, m; 
	
	scanf("%d %d", &n, &m); 
	for (i=1; i<=n; i++) {
		a.push_back(i); 
	}
	
	i = 1; 
	it = a.begin(); 
	while(!a.empty()) {
		if ((i%m)==0) {
			printf("%d ", *it); 
			it = a.erase(it); 
		} else {
			it++; 
		}
		i++; 
		if (it==a.end()) {
			it = a.begin(); 
		}
	}
	printf("\n"); 
	return 0; 
}

